<?php
/*
	Aurus CMS - free OOP CMS
	Copyright (C) 2010  Nestor Yanchuk

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
if (! defined('ROOT')) die();
class Parser_Tag_size extends Parser {
	public $tags_inside = true;
	private $font_sizes = array (1 => '8',2 => '10',3 => '12',4 => '14',5 => '18',6 => '24',7 => '36');
	
	public function get($inner,$param = ''){
		if ($param > 7) {
			$param = 7;
		} elseif ($param < 1){
			$param = 1;
		}
		return '<span style="font-size:'.$this->font_sizes[$param].'px">'.$inner.'</span>';
	}
	public function unparse($text){
		return preg_replace('~<span style=\"font-size\:([0-9]+)px\">(.+?)<\/span>~ise','self::unSize("\\1","\\2")',$text);
	}
	private function unSize($size,$text){
		$s = array_flip($this->font_sizes);
		return '[size='.$s[$size].']'.$text.'[/size]';
	}
}